package bitmap;

import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.HashMap;

public class FontReader
{

	private String path;
	private HashMap<String, int[][]> font = new HashMap<String, int[][]>();

	public FontReader(String path)
	{
		this.path = path;
	}

	public void process()
	{
		try
		{
			FileInputStream fstream = new FileInputStream(path);
			DataInputStream in = new DataInputStream(fstream);
			BufferedReader br = new BufferedReader(new InputStreamReader(in));
			String strLine;
			while ((strLine = br.readLine()) != null)
			{
				elaborateLine(strLine);
			}
			in.close();
		}
		catch (Exception e)
		{
			System.err.println("Error: " + e.getMessage());
		}

	}

	private void elaborateLine(String strLine)
	{
		String parts[]= strLine.split("\t");
		String  letter= parts[0];
		//System.out.println("letter: " + letter);
		int[][] map = new int[5][3];
		int count=1;
		for(int i=0;i<5;i++){
			for(int j=0;j<3;j++){
				map[i][j]=Integer.parseInt(parts[count++]);
			}
		}
		font.put(letter, map);
	}

	public HashMap<String, int[][]> getFont()
	{
	
		// TODO Auto-generated method stub8
		return font;
	}

	public static void main(String[] args)
	{
		FontReader fontReader = new FontReader("c:/tmp/font01.font");
		fontReader.process();
		System.out.println(fontReader.getFont());
	}
}
